#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>

#define LENGTH 1024*1024

char buf[LENGTH];


int AddStringToFile(char * str)
//int main()
{
	int fd, len, flag;

	flag = O_CREAT | O_RDWR;
	
	fd = open("/data/log", flag, S_IRUSR | S_IWUSR); 
	if (fd) {
		lseek(fd, 0, SEEK_END);

		//char buf[]="Hello, Software Weekly\n";
		memcpy(buf, str, strlen(str));
		
		write(fd, buf, strlen(buf)); 
		close(fd);
	}
	else { 
		printf("open file error.\n");
	}

#if 0		
	fd = open("/data/logHDMI.txt", O_RDONLY);
	len = read(fd, str, LENGTH); 

	str[len] = '\0';
	printf("%s\n", str);
	close(fd);
#endif

	return 0;	
}
